package com.liezh.server;

import com.liezh.service.SslThriftService;
import com.liezh.service.User;
import org.apache.thrift.TException;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author liezh
 * @date 2021-9-3
 */
public class SslThriftServiceImpl implements SslThriftService.Iface {
    @Override
    public String login(User bar) throws TException {
        InetAddress addr = null;
        try {
            addr = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        System.out.println(bar.getId() + "-" + bar.getName() + "-" + bar.getPassword());
        return "OK, Login by：" + addr.getHostAddress();
    }

    @Override
    public String queryUserInfo(String username) throws TException {
        final User session = UserSession.getSession();
        System.out.println(session.toString());
        return session.toString();
    }
}
